from http.server import BaseHTTPRequestHandler, HTTPServer
from pprint import pprint
import mimetypes

class JellyHTTPHandler(BaseHTTPRequestHandler):
    GET_FILE_WHITE_LIST = [
        '/index.html',
        '/vue.global.js',
    ]

    def do_GET(self):
        req_file = ('/index.html' if self.path == '/' else self.path)

        if req_file in self.GET_FILE_WHITE_LIST:
            req_file = f'web{req_file}'
            content_type = mimetypes.guess_file_type(req_file)[0]
            self.send_response(200)
            self.send_header('Content-Type', f'{content_type}; charset=UTF-8')
            self.end_headers()
            with open(req_file, 'rb') as f:
                self.wfile.write(f.read())
        else:
            self.send_error(404, 'Not Found')

if __name__ == '__main__':
    HTTPServer(('127.0.0.1', 16667), JellyHTTPHandler).serve_forever()